package com.lglbc;

import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author 乐哥聊编程
 * @Doc 关注公众号"乐哥聊编程"获取文档和源码
 * @Date 2023/6/10
 * @Description
 */
@RestControllerAdvice
public class GlobalException {
    @ExceptionHandler(value = FlowException.class)
    public String flowException(FlowException e) {
        return "触发限流";
    }
    @ExceptionHandler(value = DegradeException.class)
    public String degradeException(DegradeException e) {
        return "触发降级";
    }
}
